package com.buba.system.controller;

import com.buba.pojo.UserInfo;
import com.buba.system.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

//1
@Controller
public class LoginController {
    @Autowired
    private LoginService loginService;
    /**
     * 登录方法
     * @param userName
     * @param password
     * @return
     */
    @RequestMapping("/login")
    public String login(String userName, String password, HttpSession session){
      UserInfo userInfo = loginService.login(userName,password);
      if (userInfo!=null){
          session.setAttribute("login",userInfo);
          return "redirect:buba/index.jsp";

      }
        return "login";
    }
}
